<template>
  <div
    class="menuNavigation-box"
    :class="{
      'menuNavigation-item-loop': !route.meta.loopType,
      'menuNavigation-item-wap': store.isMobileType,
    }"
  >
    <div class="menuNavigation-box-child">
      <div @click="openprogres" id="menuNavigation-item" class="menuNavigation-item">
        <t-popup
          class="placement align"
          content="展览定位"
          placement="left"
          attach="#menuNavigation-item0"
          showArrow
          destroyOnClose
        >
          <div
            class="item-left"
            id="menuNavigation-item0"
            :class="{ 'item-active': showType === 1, 'is-hover': store.isMobileType }"
          >
            <div class="item-content freeIcon">&#xe663;</div>
          </div>
        </t-popup>
      </div>
      <div @click="handleMouseEnter(1)" id="menuNavigation-item" class="menuNavigation-item">
        <t-popup
          class="placement align"
          content="策展目录"
          placement="left"
          attach="#menuNavigation-item1"
          showArrow
          destroyOnClose
        >
          <div
            class="item-left"
            id="menuNavigation-item1"
            :class="{ 'item-active': showType === 1, 'is-hover': store.isMobileType }"
          >
            <div class="item-content doorIcon">&#xe679;</div>
          </div>
        </t-popup>
      </div>
      <div @click="handleMouseEnter(2)" class="menuNavigation-item">
        <t-popup
          class="placement align"
          content="更多板块"
          placement="left"
          attach="#menuNavigation-item2"
          showArrow
          destroyOnClose
        >
          <div
            class="item-left"
            id="menuNavigation-item2"
            :class="{ 'item-active': showType === 2, 'is-hover': store.isMobileType }"
          >
            <div class="item-content doorIcon">&#xe67a;</div>
          </div>
        </t-popup>
      </div>

      <div class="menuNavigation-item" @click="follow" v-if="!store.isMobileType">
        <t-popup
          class="placement align"
          content="收藏此展览"
          placement="left"
          attach="#menuNavigation-item4"
          showArrow
          destroyOnClose
        >
          <div class="item-left" id="menuNavigation-item4">
            <div v-if="commonStore.isStart" class="item-content doorIcon item-start start-active">&#xe629;</div>
            <div v-else class="item-content doorIcon item-start">&#xe628;</div>
          </div>
        </t-popup>
      </div>
      <div class="menuNavigation-item" v-if="!store.isMobileType">
        <t-popup
          class="placement align"
          content=""
          placement="left"
          attach="#menuNavigation-item5"
          destroyOnClose
          :trigger="store.isMobileType ? 'click' : 'hover'"
          :overlay-inner-style="(triggerElem) => ({ background: `transparent`, 'box-shadow': 'none' })"
        >
          <template #content>
            <Shear @shearType="shearType" />
          </template>
          <div class="item-left" id="menuNavigation-item5" :class="{ 'item-active': showType === 4 }">
            <div class="item-content doorIcon">&#xe647;</div>
          </div>
        </t-popup>
      </div>
    </div>
    <div
      v-if="(showType === 1 || showType === 2 || showType === 4) && show"
      class="scroll-box"
      :class="showType === 1 || showType === 2 || showType === 4 ? 'scroll-box-active' : 'scroll-box-down'"
    >
      <div
        class="scroll-box-content"
        :class="showType === 2 && 'scroll-box-width'"
        :style="{
          backgroundImage: `url(${publicUrls + 'free/style15/menuNavigationstyle1.png'})`,
        }"
      >
        <div class="list-content" v-if="showType === 1">
          <div class="list-heard">单元目录</div>
          <div class="list-scroll">
            <div
              class="item"
              @click="scroolPath(item.id, index)"
              v-for="(item, index) in store.templateMOdeList"
              :key="item.id"
            >
              <p class="item-title" :class="!store.isMobileType && 'item-hover'">{{ item.text }}</p>
            </div>
          </div>
        </div>
        <div class="list-content list-content-mg" v-else-if="showType === 2">
          <div class="list-heard">更多板块</div>
          <RouterList @emitPath="scrollHandleMouseLeave" />
        </div>
      </div>
    </div>
    <div
      @wheel="pageWheel"
      class="shadow"
      @click="close"
      v-if="(showType === 1 || showType === 2 || showType === 4) && show"
    ></div>
    <!-- 展开目录 -->
  </div>
</template>

<script lang="ts">
export default defineComponent({
  name: 'style15',
});
</script>

<script setup lang="ts">
import { getHeardToken } from '@/api/utils';
import { psthOutline } from '@/hooks/menuHooks';
import RouterList from '../menuComponent/routerList15.vue';
import { publicUrls } from '@/utils/minxin';
import { ref, reactive, watch, nextTick, computed, defineComponent } from 'vue';
import { useProjectStore } from '@/store';
import { commonDataStore } from '@/store';
import { toQQ, toQQzone, toWeibo } from '@/utils/shear';
import { AddFollow } from '@/api/door/door';
import Shear from '../menuComponent/templateShear.vue';
import { useRoute, useRouter } from 'vue-router';

const props = defineProps({
  isMobile: {
    type: Boolean,
  },
});
const commonStore = commonDataStore();
const show = ref(false);
const showType = ref(0);
const listId = ref(0);
const store = useProjectStore();
const visibleMessage = ref(false);
const FollowType = ref(false);
const router = useRouter();
const route = useRoute();
const shareList = reactive([
  {
    icon: '\ue623',
    text: '分享此展览到QQ',
  },
  {
    icon: '\ue616',
    text: '分享此展览到QQ空间',
  },
  {
    icon: '\ue615',
    text: '分享此展览到微博',
  },
]);

commonStore.getMenuList();
const handleMouseEnter = (type: number) => {
  showType.value = type;
  show.value = true;
};
const openprogres = () => {
  store.setprogressVisible();
};
const mouseenterHover = () => {};

const scrollHandleMouseLeave = () => {
  showType.value = 0;
  show.value = false;
};
const scroolPath = (id: number, index) => {
  if (route.name !== 'templateedit') {
    router.push({ name: route.meta.loopType ? 'exhibitionHome' : 'templateedit' });
    store.menuId = null;
  }
  if (store.previewMode !== 1) {
    store.SetpreviewModeShow();
    store.previewModuleIndex = index;
  }
  if (id !== 0) {
    setTimeout(() => {
      psthOutline('Level1outline' + id);
      scrollHandleMouseLeave();
      listId.value = id;
    }, 200);
  } else {
    const el = document.getElementById('edit-scroll-box');
    store.bannerShow = false;
    store.bannerLock = false;
    setTimeout(() => {
      el.scrollTo({
        left: 0,
      });
    }, 1000);
  }
};
const follow = () => {
  let token = getHeardToken();
  if (!token) {
    // visibleMessage.value = true;
    store.loginModeShow = true;
    return;
  } else {
    commonStore.setFollow();
    handleMouseEnter(3);
  }
};
const pageWheel = (event: any) => {
  const delta = Math.sign(event.wheelDelta || -event.detail);
  const scrollContainer = document.getElementById('edit-scroll-box');
  if (delta > 0) {
    if (scrollContainer.scrollLeft === 0) {
    } else {
      scrollContainer.scrollLeft = scrollContainer.scrollLeft - 100;
    }
  } else {
    scrollContainer.scrollLeft = scrollContainer.scrollLeft + 100;
  }
  event.preventDefault();

  // scrollRef
};
//分享
const shearType = (e: number) => {
  let url = window.location.href;
  let title = '';
  handleMouseEnter(4);
  switch (e) {
    case 0:
      toQQ(url, title);
      break;
    case 1:
      toQQzone(url, title);
      break;
    case 2:
      toWeibo(url, title);
      break;
  }
  scrollHandleMouseLeave();
};

//取消登录
const closeClick = () => {
  visibleMessage.value = false;
};
const close = () => {
  showType.value = 0;
  show.value = false;
};
//确认登录
const pathSubmitClick = () => {
  visibleMessage.value = false;
  let url = window.location.href;
  let redirectUrl = 'http://wz.wuzhan.art/#/login?redirect=' + url;
  window.location.href = redirectUrl;
};
</script>

<style lang="less" scoped>
* {
  scrollbar-width: none;
}
a {
  color: #000;
  &:hover {
    color: #000;
  }
}
.menuNavigation-box {
  display: flex;
  flex-direction: column;
  position: fixed;
  bottom: 60px;
  right: 20px;
  // right: 0px;
  width: 48px;
  z-index: 999;
}
.menuNavigation-item-loop {
}
.menuNavigation-box-child {
  position: relative;
  display: flex;
  flex-direction: column;
  padding-top: 105px;
  width: 48px;
  z-index: 999;
}

.menuNavigation-item {
  position: relative;
  cursor: pointer;
  display: flex;
  align-items: center;

  width: 48px;

  transition: all 0.3s;
  z-index: 999;
  transform: translateY(0px);
  margin-top: 20px;
  ::v-deep .t-popup {
    background: transparent !important;
  }
  ::v-deep .t-popup__content {
    padding: 0px !important;
    font-size: 12px;
    line-height: 20px;
    color: rgba(2, 76, 63, 1);
    background-color: transparent;
    box-shadow: none;
  }
  // ::v-deep .t-popup__content::before {
  //   content: '';
  //   position: absolute;
  //   top: 2.5px;
  //   left: 2px;
  //   width: calc(100% - 5px);
  //   height: calc(100% - 5px);
  //   border-radius: 3px;
  //   border: 0.5px solid rgba(87, 153, 158, 0.5);
  //   z-index: 99;
  // }
  ::v-deep .t-popup__arrow::before {
    display: none;
    background: #eff0ee;
    border: none;
    box-shadow: none;
  }
}
#menuNavigation-item1 {
  ::v-deep .t-popup__content {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 68px;
    height: 38px !important;
    background: rgba(250, 242, 226, 1);
  }
}
#menuNavigation-item0 {
  ::v-deep .t-popup__content {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 68px;
    height: 38px !important;
    background: rgba(250, 242, 226, 1);
  }
}
#menuNavigation-item2 {
  ::v-deep .t-popup__content {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 68px;
    height: 38px !important;
    background: rgba(250, 242, 226, 1);
  }
}
#menuNavigation-item3 {
  ::v-deep .t-popup__content {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 38px !important;
    width: 80px;
  }
}
#menuNavigation-item4 {
  ::v-deep .t-popup__content {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 38px !important;
    width: 80px;
    background: rgba(250, 242, 226, 1);
  }
}
#menuNavigation-item5 {
  ::v-deep .t-popup__content::before {
    display: none !important;
  }
}
.item-active {
  //   background: #ffcc36 !important;
  // background: ;
  // background-image: url(https://static.jiyi.show/free/style10/menuNavigationItemLeftActiive.png) !important;
}
.shadow {
  position: fixed;
  top: 0;
  left: 0;
  width: 1440px;
  height: 900px;
  z-index: 19;
}
.item-left {
  position: relative;
  width: 48px;
  height: 48px;
  background-repeat: no-repeat;
  background-size: 100% 100%;
  z-index: 30;
  display: flex;
  justify-content: center;
  align-items: center;
  background-image: url(https://static.jiyi.show/free/style15/menuNavigationItemLeft.png);
  background-repeat: no-repeat;
  background-size: 100% 100%;
  .doorIcon {
    font-size: 24px;
    color: rgba(94, 79, 52, 1);
  }
  .freeIcon {
    font-size: 24px;
    color: rgba(94, 79, 52, 1);
  }
  .item-start {
    font-size: 27px;
    margin-left: -1.5px;
  }
}

.menuNavigation-item:hover {
}

.item-share {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 32px;
  margin-bottom: 16px;
  &:first-child {
    margin-top: 16px;
  }
  &:hover {
    .item-share-title {
      text-decoration: underline;
      opacity: 1;
    }
  }
  .doorIcon {
    font-size: 20px;
    margin-right: 4px;
  }
  .freeIcon {
    font-size: 20px !important;
  }
  .item-share-title {
    width: 156px;
    font-family: SourceHanSerifCN;
    font-size: 16px;
    line-height: 30px;
    color: #212326;
    cursor: pointer;
    opacity: 0.8;
  }
}
.scroll-box {
  display: flex;
  align-items: center;
  position: fixed;
  bottom: 60px;
  right: 90px;
  z-index: 220;
  transform: translateZ(1px);
}
.scroll-box-down {
  opacity: 0;
}
.scroll-box-content {
  z-index: 6666;
  position: relative;
  width: 300px;
  height: 490px;
  padding: 50px 22px;
  background-size: 100% 100%;
  scrollbar-width: none;
  padding-top: 54px;

  // .list-scroll {
  //   padding-right: 10px;
  // }
}
.scroll-box-width {
  // padding: 48px 40px;
  .list-scroll {
    padding-right: 0px;
    scrollbar-width: none;
  }
}

.list-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  height: 100%;
  scrollbar-width: none;
}

.list-heard {
  display: flex;
  align-items: center;
  justify-content: center;
  background-repeat: no-repeat;
  background-size: 100% 100%;
  width: 100%;
  height: 32px;
  font-family: SourceHanSerifCN-Bold;
  font-size: 18px;
  color: rgba(94, 79, 52, 1);
  line-height: 32px;
  text-align: center;
  margin-bottom: 10px;
}
.list-scroll {
  width: 100%;
  flex: 1;
  overflow: auto;
  scrollbar-width: none;
}
// .list-scroll::-webkit-scrollbar {
//   width: 4px;
//   background: rgba(133, 134, 139, 0.3);
// }
// .list-scroll::-webkit-scrollbar-thumb {
//   background: linear-gradient(0deg, #85868b 1.93%, #85868b 100%);
// }
// .list-scroll::-webkit-scrollbar-track {
//   background: rgba(133, 134, 139, 0.3);
// }
.item {
  width: 100%;
  height: 32px;
  margin-bottom: 20px;
}
.item:last-of-type {
  margin-bottom: 0px;
}
.item-title {
  font-family: PingFang SC;
  font-size: 16px;
  font-weight: 400;
  line-height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  text-align: center;
  opacity: 0.5;
  color: rgba(94, 75, 52, 1);
}
.item-hover {
  cursor: pointer;
}
.item-hover:hover {
  opacity: 1;

  text-decoration: underline;
  text-underline-offset: 4px; /* 调整下划线与文本的距离 */
}

.menuNavigation-item-wap {
  bottom: 100px;

  .menuNavigation-item {
    // transform: translateZ(1px);
    transform: scale(1.1) translateZ(2px);
  }
  .scroll-box {
    transform: scale(1.2) translateZ(2px);
    margin-bottom: 80px;
    right: 210px;
  }
  ::v-deep .t-popup {  
    display: none;
  }
}
*{
  scrollbar-width: none;
}
</style>
